<div class="sect1">
<h2 id="_description">Description</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Certain aspects of bit-fields are implementation-defined. In particular, the developer should be aware of the following:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>It is implementation-defined whether the bit-fields are allocated from the high or low end of a storage unit (usually a byte).</p>
</li>
<li>
<p>It is implementation-defined whether or not a bit field can overlap a storage unit boundary (e.g. if a 6-bit bit-field and a 4-bit bit-field are declared in that order, then the 4-bit bit-field may either start a new byte or it may use 2 bits in one byte and 2 bits in the next).</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>These issues are generally benign (e.g. when packing together short-length data to save storage space), but they may lead to errors if the absolute position of the bit-fields is important (e.g. when accessing hardware registers).</p>
</div>
<div class="paragraph">
<p>Provided the elements of the structure are only accessed by name, the developer need make no assumptions about the way that the bit fields are stored within the structure.</p>
</div>
<div class="paragraph">
<p>Note that Rule 3-9-2 need not be followed when defining bit-fields, as their lengths are explicitly specified.</p>
</div>
<div class="paragraph">
<p>If the compiler has a switch to force bit fields to follow a particular layout, then this option should be documented.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_see_also">See Also</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p>MISRA C&#43;&#43;:2008, 3-9-2</p>
</li>
</ul>
</div>
<hr>
</div>
</div>
<div class="sect1">
<h2 id="_comments_and_links">Comments And Links</h2>
<div class="sectionbody">
<div class="paragraph">
<p>(visible only on this page)</p>
</div>
<div class="sect2">
<h3 id="_on_21_oct_2014_131509_samuel_mercier_wrote">on 21 Oct 2014, 13:15:09 Samuel Mercier wrote:</h3>
<div class="paragraph">
<p>Cannot be implemented, as this requires understanding of the developer&#8217;s intent.</p>
</div>
</div>
</div>
</div>